{% extends "forums/base.html" %}
{% from 'includes/common_macros.html' import for_contributors_sidebar %}
{% set title = _('Contributor Forums') %}
{% set crumbs = [(None, title)] %}
{% set canonical_url = canonicalize(viewname='forums.forums') %}
{% if forums.number > 1 %}
  {% set canonical_url = canonical_url|urlparams(page=forums.number) %}
{% endif %}

{% block content %}
  <div class="grid_3">
    {{ for_contributors_sidebar(user, settings.WIKI_DEFAULT_LANGUAGE, active='forums') }}
    <br />
  </div>
  <article class="grid_9">
    <div id="forums" class="content-box">
      <h1>{{ title }}</h1>

      <ol class="forums-columns cf">
        <li class="name">{{ _('Name') }}</li>
        <li class="threads">{{ _('Threads') }}</li>
        <li class="last-post">{{ _('Last Post') }}</li>
      </ol>
      {% if forums.object_list %}
        <ol class="forums">
          {% for forum in forums.object_list %}
            <li class="cf">
              <div class="name">
                <a href="{{ url('forums.threads', forum_slug=forum.slug) }}">{{ forum.name }}</a><br/>
                {{ forum.description|safe }}
              </div>
              <div class="threads">{{ forum.thread_count }}</div>
              <div class="last-post">
                {% if forum.last_post %}
                  <a href="{{ forum.last_post.get_absolute_url() }}">
                    {{ datetimeformat(forum.last_post.created) }}
                  </a><br/>
                  {{ _('by <a class="username" href="{profile_url}">{username}</a>')|fe(profile_url=profile_url(forum.last_post.author), username=display_name(forum.last_post.author)) }}
                {% else %}
                  {# Not localized because it's not worth localizers time. #}
                  No posts.
                {% endif %}
              </div>
            </li>
          {% endfor %}
        </ol>

        {{ forums|paginator }}
        {% else %}{# if forums #}
        {# Not localized because it's not worth localizers time. #}
        <p>There are no forums. You should create some!</p>
      {% endif %}
    </div>
  </article>
{% endblock %}
